<template>
    <div>
        <el-form ref="postRef" :model="form" :rules="rules" label-width="auto">
            <el-form-item label="手机号">
                <el-input v-model="form.phone" placeholder="请输入手机号"/>
            </el-form-item>
            <el-form-item label="充值金额">
                <el-input-number v-model="form.price" placeholder="请输入充值金额"/>
            </el-form-item>
            <el-form-item label="请输入登录密码">
                <el-input v-model="form.pass" type="password" show-password placeholder="请输入请输入登录密码"/>
            </el-form-item>
            <el-form-item label="&nbsp;">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import * as api from "@/api/user/user";
    export default {
      name: 'Recharge',
      components: {  },
      props: {
        uid: {
          type: Number,
          required: true
        },
        user: {
          type: Object,
          required: true
        },
      },
      data() {
        return {
          form: {},
          rules: {},
        };
      },
      mounted(){
        this.form = {
          phone: this.user.phone
        }
      },
      methods: {
        submitForm() {/** 提交按钮 */
          this.$refs["postRef"].validate(valid => {
            this.form['userid'] = this.uid
            // if (valid) {
              api.recharge(this.form).then(response => {
                  this.$modal.msgSuccess("充值成功");
                  this.$emit('close')
              });
            // }
          });
        },
        reset() {
          this.form = {};
          this.resetForm("postRef");
        },
        cancel() {
          // open.value = false;
          // reset();
          this.$emit('close')
        },
      }
    }
</script>

<style lang="scss" scoped>

</style>
